package com.primaryedu.ui.repair;

import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.VideoView;

import com.primaryedu.R;
import com.primaryedu.ui.BaseActivity;

/**
 * Created by Thomas on 2018/3/6.
 */

public class RepairVideoActivity extends BaseActivity implements View.OnClickListener {
    private VideoView vv_video;
    private String video_path = "";
    private String isclassdynamic;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_repair_video);
        init();
    }

    private void init() {
        Intent intent = getIntent();
        video_path = intent.getStringExtra("video_path");
//        isclassdynamic = intent.getStringExtra("isclassdynamic");
        ((TextView) findViewById(R.id.title)).setText("1/1");
        findViewById(R.id.back).setOnClickListener(this);
        findViewById(R.id.right).setVisibility(View.VISIBLE);
        findViewById(R.id.right).setOnClickListener(this);
//        if (isclassdynamic.equals("1")){
        ((TextView) findViewById(R.id.text_right)).setText("");
        ((TextView) findViewById(R.id.text_right)).setEnabled(false);
//        }else {
//            ((TextView) findViewById(R.id.text_right)).setText("删除");
//            ((TextView) findViewById(R.id.text_right)).setOnClickListener(this);
//            ((TextView) findViewById(R.id.text_right)).setTextColor(getResources().getColor(R.color.main_button));
//        }

        vv_video = (VideoView) findViewById(R.id.vv_video_video);
        vv_video.setOnClickListener(this);
        vv_video.setVideoPath(video_path);
        vv_video.start();
        //监听视频播放完的代码
        vv_video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {

            @Override
            public void onCompletion(MediaPlayer mPlayer) {
                // TODO Auto-generated method stub
                mPlayer.start();
                mPlayer.setLooping(true);
            }
        });
    }

    @Override
    protected int BindLayout() {
        return R.layout.activity_repair_video;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        Intent intent = null;
        switch (v.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.text_right:
//                DynamicPublishActivity.DynamicPublishActivity.finish();
//                intent = new Intent(VideoActivity.this, DynamicPublishActivity.class);
//                startActivity(intent);
//                finish();
            default:
                break;
        }
    }
}
